package com.burry.services;

import java.util.List;
import java.util.Map;

import com.burry.db.SQLMachine;

public class ContentService {
	
	public Map addAContent(String type,String title,String value){
		
		String sql = "insert into bu_content(title,type,content) values('" +title+ "','"+ type +"','"+ value +"')";
		SQLMachine sqlM = new SQLMachine("default");
		return sqlM.updateResult(sql);
		
	}
	
	public Map updateContent(String id,String type,String title,String value){
		String sql = "update bu_content set title='"+title+"',type='"+type+"',content='"+value+"' where id=" + id;
		SQLMachine sqlM = new SQLMachine("default");
		return sqlM.updateResult(sql);
	
	}
	
	public Map getAContent(String id){
		String sql = "select * from bu_content where id = " + id;
		SQLMachine sqlM = new SQLMachine("default");
		return sqlM.getResult(sql);
	}
	
	public List getAllContent(){
		String sql = "select id,title,type from bu_content";
		SQLMachine sqlM = new SQLMachine("default");
		return sqlM.getResultSet(sql);
	}
	
	public void deleteAContent(String id){
		String sql = "delete from bu_content where id = " + id;
		SQLMachine sqlM = new SQLMachine("default");
		sqlM.updateResult(sql);
	}
}
